package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicPoWareItemBatchDAO;
import com.cssy.yd.logic.entity.LogicPoWareDO;
import com.cssy.yd.logic.entity.LogicPoWareItemBatchDO;
import com.plat.helper.SearchConditions;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-10-17
 */
public class LogicPoWareItemBatchDAOImpl extends SqlMapClientDaoSupport implements LogicPoWareItemBatchDAO {

    /**
     * 插入数据
     * @param logicPoWareItemBatchDO
     * @return 插入数据的主键
     */
    public String insertLogicPoWareItemBatchDO(LogicPoWareItemBatchDO logicPoWareItemBatchDO) {
        Object id = getSqlMapClientTemplate().insert("LogicPoWareItemBatch.insert", logicPoWareItemBatchDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicPoWareItemBatchDO
     * @return 查出的记录数
     */
    public Integer countLogicPoWareItemBatchDOByExample(LogicPoWareItemBatchDO logicPoWareItemBatchDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicPoWareItemBatch.countByDOExample", logicPoWareItemBatchDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicPoWareItemBatchDO
     * @return 受影响的行数
     */
    public Integer updateLogicPoWareItemBatchDO(LogicPoWareItemBatchDO logicPoWareItemBatchDO) {
        int result = getSqlMapClientTemplate().update("LogicPoWareItemBatch.update", logicPoWareItemBatchDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicPoWareItemBatchDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicPoWareItemBatchDO> findListByExample(LogicPoWareItemBatchDO logicPoWareItemBatchDO) {
        List<LogicPoWareItemBatchDO> list = getSqlMapClientTemplate().queryForList("LogicPoWareItemBatch.findListByDO", logicPoWareItemBatchDO);
        return list;
    }

    /**
     * 根据主键获取logicPoWareItemBatchDO
     * @param id
     * @return logicPoWareItemBatchDO
     */
    public LogicPoWareItemBatchDO findLogicPoWareItemBatchDOByPrimaryKey(String id) {
        LogicPoWareItemBatchDO logicPoWareItemBatchDO = (LogicPoWareItemBatchDO) getSqlMapClientTemplate().queryForObject("LogicPoWareItemBatch.findByPrimaryKey", id);
        return logicPoWareItemBatchDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicPoWareItemBatchDOByPrimaryKey(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicPoWareItemBatch.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicPoWareItemBatchDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicPoWareItemBatchDO> list = getSqlMapClientTemplate().queryForList("LogicPoWareItemBatch_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicPoWareItemBatch_ex.count", scs);
  	      return count;
  	}
	
	@Override
	public Integer deleteLogicPoWareItemBatchDOByWareItemId(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicPoWareItemBatch_ex.deleteByWareItemId", id);
        return rows;
    }
}